package com.xiaotao.publisher;

import com.xiaotao.config.RabbitMessageUtil;
import com.xiaotao.util.ConstantUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class CreateOrderPublisher {
    @Resource
    private RabbitTemplate rabbitTemplate;

    @Resource
    private RabbitMessageUtil rabbitMessageUtil;

    public void send(String msg){
        rabbitTemplate.setConfirmCallback(rabbitMessageUtil);
        rabbitTemplate.setReturnsCallback(rabbitMessageUtil);
        rabbitTemplate.convertAndSend(ConstantUtil.EXCHANGE_CREATE_ORDER,ConstantUtil.ROUTEING_KEY_CREATE_ORDER,msg);
    }
}
